import { createRouter, createWebHistory } from 'vue-router'
import Login from '../pages/LoginPage.vue'
import Support from '../pages/SupportPage.vue'
import MainLayout from '../pages/MainLayout.vue'
import Department from "@/pages/DepartmentPage";
import User from "@/pages/UserPage";

const routes = [
    {
        path: '/',
        redirect: '/login',
    },
    {
        path: '/login',
        name: 'Login',
        component: Login,
        meta: { requiresGuest: true }
    },
    {
        path: '/main',
        component: MainLayout,
        meta: { requiresAuth: true },
        children: [
            {
                path: 'department',
                name: 'Department',
                component: Department
            },
            {
                path: 'user',
                name: 'User',
                component: User
            },
            // 新增维修申请路由
            {
                path: 'support',
                name: 'Support',
                component: Support
            },
            {
                path: '',
                redirect: { name: 'Support' }
            }
        ]
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})
console.log('Router module loaded');
export default router